package com.epam.tcs.dao.hibernate.entities;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "tcs_theme_item")
@DiscriminatorColumn(name="type", discriminatorType=DiscriminatorType.INTEGER)
public abstract class ThemeItem implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 4475847500329152191L;
	private int lecPracId;
	private String name;
	private Theme theme;
	private String description;
	private byte type;
	
	public ThemeItem(){
		
	}
	
	public void setType(byte type) {
		this.type = type;
	}
	
	@Column(name = "type", insertable = false, updatable = false)
	public byte getType() {
		return type;
	}
	
	public void setLecPracId(int lecPracId) {
		this.lecPracId = lecPracId;
	}
	
	@Id
	@Column(name ="lec_prac_id")
	@GeneratedValue(strategy=GenerationType.AUTO)
	public int getLecPracId() {
		return lecPracId;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	@Column(name = "name", length=50)
	public String getName() {
		return name;
	}

	public void setTheme(Theme theme) {
		this.theme = theme;
	}
	
	@ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH})
	@JoinColumn(name = "theme_id", nullable = false)
	public Theme getTheme() {
		return theme;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getDescription() {
		return description;
	}
}
